package com.codewsq.exer;


import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

public class ArrayTest {

    public ArraysCRUD arraysCRUD;

    @Before
    public void before() {
        // 创建一个长度20的数组
        arraysCRUD = new ArraysCRUD(20);
    }

    @Test
    public void test() {
        String[] strs = arraysCRUD.getStrs();
        System.out.println("数组中的元素:" + Arrays.toString(strs));
        System.out.println("数组元素个数:" + arraysCRUD.getTotal());
        System.out.println("------------添加元素后----------------");
        arraysCRUD.add("Tom");
        arraysCRUD.add("Jerry");
        arraysCRUD.add("Spike");
        arraysCRUD.add(1, "嘻嘻");
        System.out.println("数组中的元素:" + Arrays.toString(arraysCRUD.getStrs()));
//        arraysCRUD.add(19, "Jerry");
//        System.out.println(Arrays.toString(arraysCRUD.getStrs()));
        System.out.println("数组元素个数:" + arraysCRUD.getTotal());

        System.out.println("------------指定修改某个下标的元素----------------");
        arraysCRUD.update(2, "哈哈");
        System.out.println("数组中的元素:" + Arrays.toString(arraysCRUD.getStrs()));
        System.out.println("数组元素个数:" + arraysCRUD.getTotal());

        System.out.println("------------删除某个下标的元素----------------");
        arraysCRUD.delete(3);
        System.out.println(Arrays.toString(arraysCRUD.getStrs()));
        System.out.println("数组元素个数:" + arraysCRUD.getTotal());
    }

    @Test
    public void test1() {
        int[] nums = new int[10];
        System.out.println(nums.length);

    }
}
